import Mock from 'mockjs'
import store from '@/store'
let data = Mock.mock({
  'data|3': [
    //生成6条数据 数组
    {
      'string|5-10': '★',
      'shopId|+1': 1, //生成商品id，自增1
      shopMsg: '@ctitle(10)', //生成商品信息，长度为10个汉字
      shopName: '@cname', //生成商品名 ， 都是中国人的名字
      shopTel: /^1(5|3|7|8)[0-9]{9}$/, //生成随机电话号
      shopAddress: '@county(true)', //随机生成地址
      'shopStar|1-5': '★', //随机生成1-5个星星
      'salesVolume|30-1000': 30, //随机生成商品价格 在30-1000之间
      shopLogo: "@Image('100x40','#c33', '#ffffff','小北鼻')", //生成随机图片，大小/背景色/字体颜色/文字信息
      'food|2': [
        //每个商品中再随机生成2个food
        {
          foodName: '@cname', //food的名字
          foodPic: "@Image('100x40','#c33', '#ffffff','小可爱')", //生成随机图片，大小/背景色/字体颜色/文字信息
          'foodPrice|1-100': 20, //生成1-100的随机数
          'aname|2': [
            {
              aname: '@cname',
              'aprice|30-60': 20
            }
          ]
        }
      ]
    }
  ]
})
Mock.mock('/api/logintitle', 'get', {
  title: '畅行高速 先通行后付费',
  statuss: 10001
})
Mock.mock('/api/listpost', 'post', () => {
  //三个参数。第一个：路径，第二个：请求方式post/get，第三个：回调，返回值
  return data
})
Mock.mock('/api/listget', 'get', {
  //三个参数。第一个：路径，第二个：请求方式post/get，第三个：回调，返回值
  'data|3': [
    {
      foo: 'Hello',
      nested: {
        a: {
          b: {
            c: 'Mock.js'
          }
        }
      },
      absolutePath: 'Hello Mock.js'
    }
  ]
})
Mock.mock('/api/yanzhengmas', 'post', {
  yanzhengma: /\d{6}/,
  status: 20001
})
Mock.mock(/\/api\/login.*/, 'post', (config) => {
  // console.log(1)
  console.log(config)
  return {
    token: 'dcsacunhascsauicasciuancasinciascacnscqwrurwqidjaodjqwidja',
    tel: store.state.telnumber,
    yzm: store.state.yanzhengmas,
    status:20001
  }
})
Mock.mock('/api/agreementtitle', 'post', [
  { id: 1, img: '', title: '办卡进度', hint: '123' },
  { id: 2, img: '', title: '账单查询', hint: '账单明细' },
  { id: 3, img: '', title: '电子账户', hint: '456' },
  { id: 4, img: '', title: '我的合同', hint: '查看签署合同' },
  { id: 5, img: '', title: '推出登录', hint: '789' }
])
Mock.mock('/api/mymoto', 'post', () => {
  return {
    statusCode:
      localStorage.token ==
      'dcsacunhascsauicasciuancasinciascacnscqwrurwqidjaodjqwidja'
        ? 1
        : 0,
    statusReason: 'jwt token header is empty',
    systemCode: 0
  }
})
Mock.mock('/api/bar', 'post', () => ({
  number: [111, 222, 333, 444, 333, 222, 111],
  datatime: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
}))
Mock.mock('/api/pie', 'post', () => [
  { value: 111, name: '周一' },
  { value: 222, name: '周二' },
  { value: 333, name: '周三' },
  { value: 444, name: '周四' },
  { value: 333, name: '周五' },
  { value: 222, name: '周六' },
  { value: 111, name: '周日' }
])
